package Work04.Task02;

import java.io.*;
import java.util.*;

/**
 * @Author: lu
 * @Date: 2021/9/14 9:21
 * @Description:
 */
public class Task02 {
    public static void main(String[] args) {
        List<String> list = new ArrayList<>();
        System.out.println("请输入字符和字符串，以end结束。。。。");
        Scanner sc = new Scanner(System.in);
        BufferedReader br = null;
        BufferedWriter bw = null;
        try {
            br = new BufferedReader(new InputStreamReader(System.in));
            bw = new BufferedWriter(new FileWriter("E:\\module01\\abc.txt"));
            String line = null;
            while ((line = br.readLine())!= null){
                if("end".equals(line)){
                    break;
                }
                list.add(line);
            }
            Collections.sort(list,Collections.reverseOrder());
            for (String eachLine:list) {
                bw.write(eachLine+"\n");
            }
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            if(null!=bw){
                try {
                    bw.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            if(null!=br){
                try {
                    br.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    }
}
